﻿namespace Chaliy.Syndication.MediaRss
{
    using System;
    using System.Xml;
    using System.Xml.Serialization;
    using System.Xml.Schema;    

    /// <summary>
    ///     Represents short description describing the media object typically a sentence in length.
    /// </summary>
    [XmlRoot("description", Namespace = Namespaces.MediaRssPrivate)]
    public class MediaDescription : IXmlSerializable
    {
        /// <summary>
        /// 	Get or set value that specifies the type of text embedded. Possible values are either 'plain' or 'html'. Default value is 'plain'.
        /// </summary>
        public MediaTextType Type
        {
            get;
            set;
        }

        public string Value
        {
            get;
            set;
        }

        #region IXmlSerializable Members

        XmlSchema IXmlSerializable.GetSchema()
        {
            throw new NotSupportedException(); // TODO Implement
        }

        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            throw new NotSupportedException(); // TODO Implement
        }

        void IXmlSerializable.WriteXml(XmlWriter writer)
        {
            ArgumentUtilities.EnsureArgumentNotNull(writer, "writer");
            
            writer.WriteEnumAttribute("type", this.Type, MediaTextType.Plain);
            
            if (String.IsNullOrEmpty(this.Value) == false)
            {
                writer.WriteValue(this.Value);
            }
        }

        #endregion
    }
}
